
#include"s_workmanager.h"

manager::manager()
{
    //1.文件不存在
    ifstream ifs;
    ifs.open(FILE_WORK, ios::in);//读文件
    if (!ifs.is_open())//返回值是bool型
    {
        //cout << "文件不存在" << endl;
        //初始化记录人数
        w_num = 0;
        //初始化数组指针
        w_array = NULL;
        //初始化文件是否为空
        m_FileIsEmpty = true;
        ifs.close();
        return;
    }
   //文件存在，但数据为空
    char ch;
    ifs >> ch;
    if(ifs.eof())
    {
        cout << "文件为空" << endl;
        //初始化记录人数
        w_num = 0;
        //初始化数组指针
        w_array = NULL;
        //初始化文件是否为空
        m_FileIsEmpty = true;
        ifs.close();
        return;
    }
    //文件存在，并且记录数据
    w_num = get_EmpNum();
    
    //开辟空间
    w_array = new work[w_num];
    //将文件中的数据存到数组中
    init_Emp();
    //更新职工不为空标志
    m_FileIsEmpty = false;
    ifs.close();
}

manager::~manager()
{
    if(w_array != NULL)
    {
        delete []w_array;
    }
}

//读取文件中的作品数量
int manager::get_EmpNum()
{
    ifstream ifs;
    ifs.open(FILE_WORK, ios::in);//打开文件 -- 读
    string name;
    int size;
    int views;
    int likes;
    int comments;
    int year;
    int month;
    int day;
    bool privacy;
    int num = 0;//记录数量
    while (ifs >> name && ifs >> size && ifs >> views && ifs >> likes && ifs >> comments && ifs >> year && ifs >> month && ifs >> day && ifs >> privacy)
    {
        num++;
    }
    ifs.close();
    return num;
}
//初始化
void manager::init_Emp()
{
    ifstream ifs;
    ifs.open(FILE_WORK, ios::in);

    string name;
    int size;
    int views;
    int likes;
    int comments;
    int year;
    int month;
    int day;
    bool privacy;
    int index = 0;
    while (ifs >> name && ifs >> size && ifs >> views && ifs >> likes && ifs >> comments && ifs >> year && ifs >> month && ifs >> day && ifs >> privacy)
    {
        w_array[index].name = name;
        w_array[index].size = size;
        w_array[index].views = views;
        w_array[index].likes = likes;
        w_array[index].comments = comments;
        w_array[index].time.year = year;
        w_array[index].time.month = month;
        w_array[index].time.day = day;
        w_array[index].privacy = privacy;
        index++;
    }
   
    ifs.close();
}
//保存文件
void manager::save()
{
    ofstream ofs;
    ofs.open(FILE_WORK, ios::out);//用输出的方式打开文件 -- 写文件
    for(int i = 0; i < w_num; i++)
    {
        ofs << w_array[i].name << " "
        << w_array[i].size << " "
        << w_array[i].views << " "
        << w_array[i].likes << " "
        << w_array[i].comments << " "
        << w_array[i].time.year << " "
        << w_array[i].time.month << " "
        << w_array[i].time.day << " "
        << w_array[i].privacy << endl;
    }
    //关闭文件
    ofs.close();
}
//清空文件
void manager::Clean_File()
{
    while(1)
    {
        cout << "确认清空？" << endl;
        cout << "1.确认" << endl;
        cout << "2.返回" << endl;
        int select = 0;
        cin >> select;
        if(select == 1)
        {
            //打开模式 ios::trunc 如果存在，则删除文件并重新创建
            ofstream ofs(FILE_WORK, ios::trunc);
            ofs.close();
            if (w_array != NULL)
            {
                delete []w_array;
                w_num = 0;
                w_array = NULL;
                m_FileIsEmpty = true;
            }
            cout << "清除成功！" << endl;
            break;
        }
        else if(select == 2)
        {
            break;
        }
        else
        {
            cout << "您的输入有误，请重新输入！" << endl;
        }
    }
}

//发布（增加）作品
void manager::Add_work()
{
    //功能描述：发布新作品，并且保存到文件中
   while (1)
   {
        cout << "请输入添加作品数量：" << endl;
        int add_num;//保存发布作品的输入数量
        cin >> add_num;
        //作为是否退出循环的操作
        bool flag = false;
        if(add_num > 0)
        {
            //计算新空间的大小
            int newSize = w_num + add_num;
            //开辟新空间
            work * newSpace = new work[newSize];
            //将原空间下内容拷贝到新空间下
            if(w_array != NULL)
            {
                for(int i = 0; i < w_num; i++)
                {
                    newSpace[i] = w_array[i];
                }
            }
            //输入新数据
            for(int j = 0; j < add_num; j++)
            {
                //创立一个临时的对象用于储存新增加的作品
                work short_time;
                cout << "请输入第" << j+1 << "个作品的名字：" << endl;
                cin >> short_time.name;
                    
                cout << "请输入第" << j+1 << "个作品的大小：" << endl;
                cin >> short_time.size;
                cout << "请输入第" << j+1 << "个作品的被浏览量：" << endl;
                cin >> short_time.views;
                cout << "请输入第" << j+1 << "个作品的被点赞量：" << endl;
                cin >> short_time.likes;
                cout << "请输入第" << j+1 << "个作品的被评论量：" << endl;
                cin >> short_time.comments;
                //检验作品发布的时间是否正常
                while(1)
                {
                    cout << "请输入第" << j+1 << "个作品发布的时间：" << endl;
                    cout << "年：";
                    int short_year;
                    cin >> short_year;
                    cout << "月：";
                    int short_month;
                    cin >> short_month;
                    cout << "日：";
                    int short_day;
                    cin >> short_day;
                    if(date().Check_time(short_year, short_month, short_day))
                    {
                        short_time.time.year = short_year;
                        short_time.time.month = short_month;
                        short_time.time.day = short_day;
                        break;
                    }
                    else
                    {
                        cout << "这是一个错误的日期，请重新输入！" << endl;
                    }
                }
                //确定是否要隐藏
                while(1)
                {
                    cout << "请确定该作品是否隐藏：" << endl;
                    cout << "1.Yes" << endl;
                    cout << "2.No" << endl;
                    int choose;//选择字符
                    cin >> choose;
                    //作为标志，判断循环是否要结束
                    bool p_flag = false;
                    switch(choose)
                    {
                        case 1:
                            short_time.privacy = true;
                            break;
                        case 2:
                            short_time.privacy = false;
                            break;
                        default:
                            //更改标志
                            p_flag = true;
                            cout << "您的输入有误，请重新输入！" << endl;
                            break;
                    }
                    if(p_flag == false)
                    {
                        break;
                    }
                }
                //发布作品完成后，保存到数组中
                newSpace[w_num+j] = short_time;
            }
            //释放在堆区创建的内存
            delete[] w_array;
            //更改新空间的指向
            w_array = newSpace;
            //更新新的作品数
            w_num = newSize;
             //提示添加成功
            cout << "成功发布" << add_num << "个作品" << endl;
            //将新添加的作品存到文件中
            save();
            m_FileIsEmpty = false;
        }
        else
        {
            cout << "请重新输入" << endl;
            //更改标志
            flag = true;
        }
        if(flag == false)
        {
            break;
        }
    }
}

//按照作品名字判断作品是否存在，若存在，返回作品在数组中的位置，若不存在，则返回-1，若有多个重名的作品，则返回-2
int manager::IsExist(string del_name)
{
    int index = -1;
    //作为是否有多个重名的作品
    int flag = 0;
    for(int i = 0; i < w_num; i++)
    {
        if(w_array[i].name == del_name)
        {
            //找到作品
            index = i;
            flag++;
        }
    }
    if(flag != 1)
    {
        index = -2;
    }
    return index;
}
//删除作品
void manager::Del_work()
{
    if(m_FileIsEmpty == true)
    {
        cout << "这是一个空文件，没有数据！" << endl;
    }
    else
    {
        cout << "请输入想删除的作品名字：" << endl;
        string del_name;
        cin >> del_name;
        int index = IsExist(del_name);
        //说明找到了作品，但是有重名的作品
        if(index == -2)
        {
            cout << "有多个名为" << del_name << "的作品，请确定您想要删除的是哪一个" << endl;
            while(1)
            {
                bool flag = true;
                //展示所有重名的作品
                for(int i = 0; i < w_num; i++)
                {
                    if(del_name == w_array[i].name)
                    {
                        cout << "搜索到的作品信息为：" << endl;
                        cout << "序号为：" << i << "\t";
                        cout << "名称为：" << w_array[i].name << "\t";
                        cout << "大小为：" << w_array[i].size << "\t";
                        cout << "点赞量为：" << w_array[i].likes  << "\t";
                        cout << "浏览量为：" << w_array[i].views << "\t";
                        cout << "被评论量为：" << w_array[i].comments << "\t";
                        cout << "日期为：" << w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
                        
                    }
                }
                int choose;
                cin >> choose;
                while(1)
                {
                    cout << "请确定这是否是您想要删除的作品：" << endl;
                    cout << "名称为：" << w_array[choose].name << "\t";
                    cout << "大小为：" << w_array[choose].size << "\t";
                    cout << "点赞量为：" << w_array[choose].likes << "\t";
                    cout << "浏览量为：" << w_array[choose].views  << "\t";
                    cout << "被评论量为：" << w_array[choose].comments << "\t";
                    cout << "日期为：" << w_array[choose].time.year << "/" << w_array[choose].time.month << "/" << w_array[choose].time.day << endl;
                    cout << "1.Yes" << endl;
                    cout << "2.NO" << endl;
                    int choice;
                    cin >> choice;
                    if(choice == 1)
                    {
                        for(int j = choose; j < w_num - 1; j++)
                        {
                            //数据前移
                            w_array[j] = w_array[j+1];
                        }
                        //更新数组中记录作品个数
                        w_num--;
                        //数据同步更新到文件中
                        save();
                        cout << "删除成功！" << endl;
                        break;
                    }
                    else if(choice == 2)
                    {
                        //更改标志
                        flag = false;
                        break;
                    }
                    else
                    {
                        cout << "您的输入有误，请重新输入！";
                    }
                }
                if(flag == true)
                {
                    break;
                }
            }
        }
        
        //说明找到了该作品，且没有多个重名的作品，并且要删除掉index位置上的作品
        else if(index != -1 && index != -2)
        {
            for(int i = index; i < w_num - 1; i++)
            {
                //数据前移
                w_array[i] = w_array[i+1];
            }
            //更新数组中记录作品个数
            w_num--;
            //数据同步更新到文件中
            save();
            cout << "删除成功！" << endl;
        }
        else
        {
            cout << "未找到该作品，删除失败！" << endl;
        }
    }
    
}

//查找一段时间段的作品
void manager::find_works()
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        int f_year;
        int f_month;
        int f_day;

        int t_year;
        int t_month;
        int t_day;
        cout << "请输入你需要查找时间段从：" << endl;
        cout << "年：";
        cin >> f_year;
        cout << "月：";
        cin >> f_month;
        cout << "日：";
        cin >> f_day;
        cout << "到：" << endl;
        cout << "年：";
        cin >> t_year;
        cout << "月:";
        cin >> t_month;
        cout << "日:";
        cin >> t_day;

        bool flag = false;
        for(int i = 0; i < w_num; i++)
        {
            if(w_array[i].time.year <= t_year && w_array[i].time.year >= f_year)//年
            {
                if(w_array[i].time.month <= t_month && w_array[i].time.month >= f_month)//月
                {
                    if(w_array[i].time.day <= t_day && w_array[i].time.day >= f_day)//日
                    {
                        //确定该作品没有隐藏
                        if(w_array[i].privacy == false)
                        {
                            cout << "搜索到的作品信息为：" << endl;
                            cout << "名称为：" << w_array[i].name << "\t";
                            cout << "大小为：" << w_array[i].size << "\t";
                            cout << "点赞量为：" << w_array[i].likes << "\t";
                            cout << "浏览量为：" << w_array[i].views << "\t";
                            cout << "被评论量为：" << w_array[i].comments << "\t";
                            cout << "日期为：" << w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
                            //更改标志
                            flag = true;
                        }
//                        else//该作品不在查找范围内
//                        {
//                          cout << "该时间段内不存在作品" << endl;
//                          break;
//                        }
                    }
//                    else//该作品不在查找范围内
//                    {
//                      cout << "该时间段内不存在作品" << endl;
//                      break;
//                    }
                        
                }
//                else//该作品不在查找范围内
//                {
//                  cout << "该时间段内不存在作品" << endl;
//                  break;
//                }
                //break;
            }
//            else//该作品不在查找范围内
//            {
//             cout << "该时间段内不存在作品" << endl;
//             break;
//            }
        }
        if(flag == false)
        {
            cout << "该时间段内不存在作品" << endl;
        }
    }
 }
//按照名称来查找作品
void manager::find_by_name()
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        //输入的名字
        string t_name;
        cout << "请输入你需要查找的作品名称为:" << endl;
        cin >> t_name;
        bool flag = false;
        for(int i = 0; i < w_num; i++)
        {
            cout << "搜索到的作品信息为：" << endl;
            if(t_name == w_array[i].name)
            {
                cout << "名字：" << w_array[i].name << "\t";
                cout << "大小：" << w_array[i].size << "\t";
                cout << "被点赞量：" << w_array[i].likes << "\t";
                cout << "被浏览量：" << w_array[i].views << "\t";
                cout << "被评论量：" << w_array[i].comments << "\t";
                cout << "日期：" <<  w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
                flag = true;
                
            }
            //该作品不在查找范围内
//            else
//            {
//                cout << "不存在该作品" << endl;
//                break;
//            }
        }
        if(flag == true)
        {
            cout << "不存在该作品" << endl;
        }
    }
}

//列表展示(全部显示）
void manager::show()
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件是个空文件，没有数据！" << endl;
    }
    else
    {
        cout << "作品的相关信息如下：" << endl;
        for(int i = 0; i < w_num ; i++)
        {
            cout << "名字：" << w_array[i].name << "\t";
            cout << "大小：" << w_array[i].size << "\t";
            cout << "被点赞量：" << w_array[i].likes << "\t";
            cout << "被浏览量：" << w_array[i].views << "\t";
            cout << "被评论量：" << w_array[i].comments << "\t";
            cout << "日期：" <<  w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
        }
    }
}
//作品列表的部分显示（未隐藏）
void manager::sub_show()
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        cout << "作品的相关信息如下：" << endl;
        for(int i = 0; i < w_num; i++)
        {
            //判断该作品是否为隐藏
            if(w_array[i].privacy == false)
            {
                cout << "名字：" << w_array[i].name << "\t";
                cout << "大小：" << w_array[i].size << "\t";
                cout << "被点赞量：" << w_array[i].likes << "\t";
                cout << "被浏览量：" << w_array[i].views << "\t";
                cout << "被评论量：" << w_array[i].comments << "\t";
                cout << "日期：" <<  w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
            }
        }
    }
        
}
//作品列表的部分显示（隐藏）
void manager::show_privacy()
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        cout << "作品的相关信息如下：" << endl;
        for(int i = 0; i < w_num; i++)
        {
            //判断该作品是否为隐藏
            if(w_array[i].privacy == true)
            {
                cout << "名字：" << w_array[i].name << "\t";
                cout << "大小：" << w_array[i].size << "\t";
                cout << "被点赞量：" << w_array[i].likes << "\t";
                cout << "被浏览量：" << w_array[i].views << "\t";
                cout << "被评论量：" << w_array[i].comments << "\t";
                cout << "日期：" <<  w_array[i].time.year << "/" << w_array[i].time.month << "/" << w_array[i].time.day << endl;
            }
        }
    }
}


//按照作品大小排序
void manager::rank_size(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        //冒泡排序
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                if(wor[j].size > wor[j+1].size)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
    }
    
}
//按照作品名排序
void manager::rank_name(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                if(wor[j].name > wor[j+1].name)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
    }
    
}
//按照作品被浏览量排序
void manager::rank_views(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                if(wor[j].views > wor[j+1].views)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
            
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
    }
    
}
//按照作品被点赞量排序
void manager::rank_likes(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                if(wor[j].likes > wor[j+1].likes)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
    }
    
}
//按照作品被评论量排序
void manager::rank_comments(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                if(wor[j].comments > wor[j+1].comments)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
    }
    
}
//按照作品时间排序
void manager::rank_time(int num, work * wor)
{
    if(m_FileIsEmpty == true)
    {
        cout << "文件为空文件，没有数据！" << endl;
    }
    else
    {
        for(int i = 0; i < num - 1; i++)
        {
            for(int j = 0; j < num-1-i; j++)
            {
                //时间比对较为复杂，所以可以更改思路，将年月日统一成一个单位进行比对
                //这里假设一年等于十二个月，一个月等于三十天，或者其他的数值均是一般
                //作用均为统一比较标准
                int first;
                int second;
                first = 12 * 30 * wor[j].time.year + 30 * wor[j].time.month + wor[j].time.day;
                second = 12 * 30 * wor[j+1].time.year + 30 * wor[j+1].time.month + wor[j+1].time.day;
                if(first > second)
                {
                    work temp = wor[j+1];
                    wor[j+1] = wor[j];
                    wor[j] = temp;
                }
            }
        }
        for(int k = 0; k < num; k++)
        {
            cout << "名字：" << w_array[k].name << "\t";
            cout << "大小：" << w_array[k].size << "\t";
            cout << "被点赞量：" << w_array[k].likes << "\t";
            cout << "被浏览量：" << w_array[k].views << "\t";
            cout << "被评论量：" << w_array[k].comments << "\t";
            cout << "日期：" <<  w_array[k].time.year << "/" << w_array[k].time.month << "/" << w_array[k].time.day << endl;
        }
        
    }
    
}


//菜单函数
void manager::menu()
{
    while(1)
    {
        bool flag = false;
        cout << "请选择您想要进行操作：" << endl;
        cout << "0.返回主菜单" << endl;
        cout << "1.添加作品" << endl;
        cout << "2.显示所有作品" << endl;
        cout << "3.显示未隐藏作品" << endl;
        cout << "4.显示隐藏作品" << endl;
        cout << "5.删除作品" << endl;
        cout << "6.删除所有作品" << endl;
        cout << "7.作品排序" << endl;
        cout << "8.查找一段时间的作品" << endl;
        int choose;
        cin >> choose;
        switch(choose)
        {
            case 0:
                return;
            case 1:
                Add_work();
                break;
            case 2:
                show();
                break;
            case 3:
                sub_show();
                break;
            case 4:
                show_privacy();
                break;
            case 5:
                Del_work();
                break;
            case 6:
                Clean_File();
                break;
            case 7:
            {
                while(1)
                {
                    bool flag_sec = false;
                    cout << "0.返回上一级菜单" << endl;
                    cout << "1.按作品大小排序" << endl;
                    cout << "2.按作品名排序" << endl;
                    cout << "3.按作品被浏览量排序" << endl;
                    cout << "4.按作品点赞量排序" << endl;
                    cout << "5.按作品被评论量排序" << endl;
                    cout << "6.按作品时间排序" << endl;
                    int choice;
                    cin >> choice;
                    switch(choice)
                    {
                        case 0:
                            flag = true;
                            return;
                        case 1:
                            rank_size(w_num, w_array);
                            break;
                        case 2:
                            rank_name(w_num, w_array);
                            break;
                        case 3:
                            rank_views(w_num, w_array);
                            break;
                        case 4:
                            rank_likes(w_num, w_array);
                            break;
                        case 5:
                            rank_comments(w_num, w_array);
                            break;
                        case 6:
                            rank_time(w_num, w_array);
                            break;
                        default:
                            cout << "您的输入有误，请重新输入！" << endl;
                            flag_sec = true;
                            break;
                    }
                    if(flag_sec == false)
                    {
                        break;
                    }
                }
                break;
            }
            case 8:
                find_works();
                break;
            default:
                cout << "您的输入有误，请重新输入！" << endl;
//                flag = true;
                break;
        }
//        if(flag == false)
//        {
//            break;
//        }
    }
}




